
struct-sizeof.o:     file format elf32-littlearm


Disassembly of section .text:

00000000 <main>:
{
    char * gga;
};

void main()
{
   0:	e92d4800 	push	{fp, lr}
   4:	e28db004 	add	fp, sp, #4
   8:	e24dd010 	sub	sp, sp, #16
    struct nema * p = NULL;
   c:	e3a03000 	mov	r3, #0
  10:	e50b3008 	str	r3, [fp, #-8]
    struct queue * qu = NULL; 
  14:	e3a03000 	mov	r3, #0
  18:	e50b300c 	str	r3, [fp, #-12]
    struct point p_a, * p_b;

    printf("struct size = %ld\n", sizeof(struct nema));   // 16
  1c:	e3a01010 	mov	r1, #16
  20:	e59f0224 	ldr	r0, [pc, #548]	; 24c <main+0x24c>
  24:	ebfffffe 	bl	0 <printf>
    printf("struct size = %ld\n", sizeof(struct queue));  // 24
  28:	e3a01010 	mov	r1, #16
  2c:	e59f0218 	ldr	r0, [pc, #536]	; 24c <main+0x24c>
  30:	ebfffffe 	bl	0 <printf>

    p = (struct nema *)malloc(sizeof(struct nema));
  34:	e3a00010 	mov	r0, #16
  38:	ebfffffe 	bl	0 <malloc>
  3c:	e1a03000 	mov	r3, r0
  40:	e50b3008 	str	r3, [fp, #-8]
    printf("struct size = %ld\n", sizeof(p));   // 8
  44:	e3a01004 	mov	r1, #4
  48:	e59f01fc 	ldr	r0, [pc, #508]	; 24c <main+0x24c>
  4c:	ebfffffe 	bl	0 <printf>

    strcpy(p->gga, "abcdef");
  50:	e51b3008 	ldr	r3, [fp, #-8]
  54:	e59f21f4 	ldr	r2, [pc, #500]	; 250 <main+0x250>
  58:	e1a00003 	mov	r0, r3
  5c:	e1a01002 	mov	r1, r2
  60:	e3a03007 	mov	r3, #7
  64:	e1a02003 	mov	r2, r3
  68:	ebfffffe 	bl	0 <memcpy>
    printf("gga = %s\n", p->gga);  // abcdef
  6c:	e51b3008 	ldr	r3, [fp, #-8]
  70:	e1a01003 	mov	r1, r3
  74:	e59f01d8 	ldr	r0, [pc, #472]	; 254 <main+0x254>
  78:	ebfffffe 	bl	0 <printf>

    qu = (struct queue *) malloc (sizeof(struct queue));
  7c:	e3a00010 	mov	r0, #16
  80:	ebfffffe 	bl	0 <malloc>
  84:	e1a03000 	mov	r3, r0
  88:	e50b300c 	str	r3, [fp, #-12]
    qu->queue = (struct nema *) malloc (sizeof(struct nema));
  8c:	e3a00010 	mov	r0, #16
  90:	ebfffffe 	bl	0 <malloc>
  94:	e1a03000 	mov	r3, r0
  98:	e1a02003 	mov	r2, r3
  9c:	e51b300c 	ldr	r3, [fp, #-12]
  a0:	e5832000 	str	r2, [r3]
    strcpy(qu->queue->gga, "xiaozhi");  // 没有上面一行会段出错
  a4:	e51b300c 	ldr	r3, [fp, #-12]
  a8:	e5933000 	ldr	r3, [r3]
  ac:	e1a02003 	mov	r2, r3
  b0:	e59f31a0 	ldr	r3, [pc, #416]	; 258 <main+0x258>
  b4:	e1a00002 	mov	r0, r2
  b8:	e1a01003 	mov	r1, r3
  bc:	e3a03008 	mov	r3, #8
  c0:	e1a02003 	mov	r2, r3
  c4:	ebfffffe 	bl	0 <memcpy>
    printf("queue->gga = %s\n", qu->queue->gga);
  c8:	e51b300c 	ldr	r3, [fp, #-12]
  cc:	e5933000 	ldr	r3, [r3]
  d0:	e1a01003 	mov	r1, r3
  d4:	e59f0180 	ldr	r0, [pc, #384]	; 25c <main+0x25c>
  d8:	ebfffffe 	bl	0 <printf>
    free(qu->queue);
  dc:	e51b300c 	ldr	r3, [fp, #-12]
  e0:	e5933000 	ldr	r3, [r3]
  e4:	e1a00003 	mov	r0, r3
  e8:	ebfffffe 	bl	0 <free>
    qu->queue = NULL;
  ec:	e51b300c 	ldr	r3, [fp, #-12]
  f0:	e3a02000 	mov	r2, #0
  f4:	e5832000 	str	r2, [r3]

    qu->queue = p;
  f8:	e51b300c 	ldr	r3, [fp, #-12]
  fc:	e51b2008 	ldr	r2, [fp, #-8]
 100:	e5832000 	str	r2, [r3]
    printf("queue->gga = %s\n", qu->queue->gga);  // abcdef
 104:	e51b300c 	ldr	r3, [fp, #-12]
 108:	e5933000 	ldr	r3, [r3]
 10c:	e1a01003 	mov	r1, r3
 110:	e59f0144 	ldr	r0, [pc, #324]	; 25c <main+0x25c>
 114:	ebfffffe 	bl	0 <printf>

    printf("struct point size = %ld\n", sizeof(struct point));  // 8
 118:	e3a01004 	mov	r1, #4
 11c:	e59f013c 	ldr	r0, [pc, #316]	; 260 <main+0x260>
 120:	ebfffffe 	bl	0 <printf>
    
    p_a.gga = "eeef";
 124:	e59f3138 	ldr	r3, [pc, #312]	; 264 <main+0x264>
 128:	e50b3014 	str	r3, [fp, #-20]	; 0xffffffec
    printf("p_a.gga = %s\n", p_a.gga);   // eeef
 12c:	e51b3014 	ldr	r3, [fp, #-20]	; 0xffffffec
 130:	e1a01003 	mov	r1, r3
 134:	e59f012c 	ldr	r0, [pc, #300]	; 268 <main+0x268>
 138:	ebfffffe 	bl	0 <printf>

    p_a.gga = "fffa";
 13c:	e59f3128 	ldr	r3, [pc, #296]	; 26c <main+0x26c>
 140:	e50b3014 	str	r3, [fp, #-20]	; 0xffffffec
    printf("p_a.gga = %s\n", p_a.gga);   // fffa
 144:	e51b3014 	ldr	r3, [fp, #-20]	; 0xffffffec
 148:	e1a01003 	mov	r1, r3
 14c:	e59f0114 	ldr	r0, [pc, #276]	; 268 <main+0x268>
 150:	ebfffffe 	bl	0 <printf>

    //p_b->gga = "llkjl";
    //printf("p_b->gga = %s\n", p_b->gga);  // segmentation fault

    p_b = (struct point *) malloc (sizeof(struct point));
 154:	e3a00004 	mov	r0, #4
 158:	ebfffffe 	bl	0 <malloc>
 15c:	e1a03000 	mov	r3, r0
 160:	e50b3010 	str	r3, [fp, #-16]
    p_b->gga = "llkjlasdfasdfasdfasdfasdfads";
 164:	e51b3010 	ldr	r3, [fp, #-16]
 168:	e59f2100 	ldr	r2, [pc, #256]	; 270 <main+0x270>
 16c:	e5832000 	str	r2, [r3]
    printf("p_b->gga = %s\n", p_b->gga);  // llkjlasdfasdfasdfasdfasdfads
 170:	e51b3010 	ldr	r3, [fp, #-16]
 174:	e5933000 	ldr	r3, [r3]
 178:	e1a01003 	mov	r1, r3
 17c:	e59f00f0 	ldr	r0, [pc, #240]	; 274 <main+0x274>
 180:	ebfffffe 	bl	0 <printf>
    // strcpy(p_b->gga, "hello asm\n");      // segmentation fault
    // printf("p_b->gga = %s\n", p_b->gga);

    p_b->gga = p_a.gga;
 184:	e51b2014 	ldr	r2, [fp, #-20]	; 0xffffffec
 188:	e51b3010 	ldr	r3, [fp, #-16]
 18c:	e5832000 	str	r2, [r3]
    printf("p_b->gga = %s\n", p_b->gga);    // fffa
 190:	e51b3010 	ldr	r3, [fp, #-16]
 194:	e5933000 	ldr	r3, [r3]
 198:	e1a01003 	mov	r1, r3
 19c:	e59f00d0 	ldr	r0, [pc, #208]	; 274 <main+0x274>
 1a0:	ebfffffe 	bl	0 <printf>

    p_b->gga = (char *) malloc (sizeof(char) * 32);
 1a4:	e3a00020 	mov	r0, #32
 1a8:	ebfffffe 	bl	0 <malloc>
 1ac:	e1a03000 	mov	r3, r0
 1b0:	e1a02003 	mov	r2, r3
 1b4:	e51b3010 	ldr	r3, [fp, #-16]
 1b8:	e5832000 	str	r2, [r3]
    //p_b->gga = "kkkkkkkk"; // 使用这种时无需申请内存，用它上面的代码直接用，指向这串字符串
    //printf("p_b->gga = %s\n", p_b->gga);  // kkkkkkk
    strcpy(p_b->gga, "hello asm");          // 开启上面的注释代码，strcpy将会s fault, 因为指向一段匿名内存后不可更改。 
 1bc:	e51b3010 	ldr	r3, [fp, #-16]
 1c0:	e5933000 	ldr	r3, [r3]
 1c4:	e59f20ac 	ldr	r2, [pc, #172]	; 278 <main+0x278>
 1c8:	e1a00003 	mov	r0, r3
 1cc:	e1a01002 	mov	r1, r2
 1d0:	e3a0300a 	mov	r3, #10
 1d4:	e1a02003 	mov	r2, r3
 1d8:	ebfffffe 	bl	0 <memcpy>
    printf("p_b->gga = %s\n", p_b->gga);    // hello asm
 1dc:	e51b3010 	ldr	r3, [fp, #-16]
 1e0:	e5933000 	ldr	r3, [r3]
 1e4:	e1a01003 	mov	r1, r3
 1e8:	e59f0084 	ldr	r0, [pc, #132]	; 274 <main+0x274>
 1ec:	ebfffffe 	bl	0 <printf>

    p_b->gga = p_a.gga;
 1f0:	e51b2014 	ldr	r2, [fp, #-20]	; 0xffffffec
 1f4:	e51b3010 	ldr	r3, [fp, #-16]
 1f8:	e5832000 	str	r2, [r3]
    printf("p_b->gga = %s\n", p_b->gga);    // fffa
 1fc:	e51b3010 	ldr	r3, [fp, #-16]
 200:	e5933000 	ldr	r3, [r3]
 204:	e1a01003 	mov	r1, r3
 208:	e59f0064 	ldr	r0, [pc, #100]	; 274 <main+0x274>
 20c:	ebfffffe 	bl	0 <printf>

    strcpy(p_b->gga, "ac asm");             // segmentation fault. because malloc address lose 
 210:	e51b3010 	ldr	r3, [fp, #-16]
 214:	e5933000 	ldr	r3, [r3]
 218:	e59f205c 	ldr	r2, [pc, #92]	; 27c <main+0x27c>
 21c:	e1a00003 	mov	r0, r3
 220:	e1a01002 	mov	r1, r2
 224:	e3a03007 	mov	r3, #7
 228:	e1a02003 	mov	r2, r3
 22c:	ebfffffe 	bl	0 <memcpy>
    printf("p_b->gga = %s\n", p_b->gga);    // 
 230:	e51b3010 	ldr	r3, [fp, #-16]
 234:	e5933000 	ldr	r3, [r3]
 238:	e1a01003 	mov	r1, r3
 23c:	e59f0030 	ldr	r0, [pc, #48]	; 274 <main+0x274>
 240:	ebfffffe 	bl	0 <printf>

}
 244:	e24bd004 	sub	sp, fp, #4
 248:	e8bd8800 	pop	{fp, pc}
 24c:	00000000 	.word	0x00000000
 250:	00000014 	.word	0x00000014
 254:	0000001c 	.word	0x0000001c
 258:	00000028 	.word	0x00000028
 25c:	00000030 	.word	0x00000030
 260:	00000044 	.word	0x00000044
 264:	00000060 	.word	0x00000060
 268:	00000068 	.word	0x00000068
 26c:	00000078 	.word	0x00000078
 270:	00000080 	.word	0x00000080
 274:	000000a0 	.word	0x000000a0
 278:	000000b0 	.word	0x000000b0
 27c:	000000bc 	.word	0x000000bc
